<?php $title='Fitness articles - add'; ?>
<?php include('fns_db_articles.php'); ?>
<?php include('../views/layouts/_header.php'); ?>
<?php include('../views/layouts/_left.php'); ?>
<?php
	//include('../check_if_admin.php');
	if(!checkIfAdmin()){
		header("location: articles.php");
	}
?>
<?php include_once("../fckeditor/fckeditor.php") ;?>
<script language="JavaScript" type="text/javascript">
function formatText (tag) {
	tagstart = "<" + tag + ">";
	tagend = "</" + tag + ">";

	//code for Mozilla
	el = document.getElementById('articleText');
	if (el.setSelectionRange) {
 		el.value = el.value.substring(0,el.selectionStart) + tagstart + el.value.substring(el.selectionStart,el.selectionEnd) + tagend + el.value.substring(el.selectionEnd,el.value.length)
  	}
  	else {
  		//code for IE
	    var selectedText = document.selection.createRange().text;

	    if (selectedText != "") {
	        var newText = tagstart + selectedText + tagend;
	        document.selection.createRange().text = newText;
	    }
  	}
}

function setFontSize (size) {

	tagstart = "<span style='font-size:" + size + "'>";
	tagend = "</span>";

	//code for Mozilla
	el = document.getElementById('articleText');
	if (el.setSelectionRange) {
 		el.value = el.value.substring(0,el.selectionStart) + tagstart + el.value.substring(el.selectionStart,el.selectionEnd) + tagend + el.value.substring(el.selectionEnd,el.value.length)
  	}
  	else {
  		//code for IE
	    var selectedText = document.selection.createRange().text;

	    if (selectedText != "") {
	        var newText = tagstart + selectedText + tagend;
	        document.selection.createRange().text = newText;
	    }
  	}
}
</script>


Adding new article:<br/><br/>

<form name="form1" method="post" action="manage_articles.php?action=add" enctype="multipart/form-data">

	<table width="250" border="0" class="main-content-text" >
	  <tr>
	    <td>Title:</td>
	    <td><input type="text" name="title" id="title"></td>
	  </tr>
	  <tr>
	    <td>Description:</td>
	    <td><input type="text" name="description" id="description"></td>
	  </tr>
	  <!--<tr>
	    <td>Date:</td>
	    <td><input name="date" type="text" id="date" value="2008-04-21"></td>
	  </tr>-->
	  <tr>
	    <td>Author:</td>
	    <td><input type="text" name="author" id="author"></td>
	  </tr>
	  <tr>
	    <td>Attach photo:</td>
	    <td><input name="img_file" type="file"  />
	    <br/>(images must be less than 2MB and in jpg format)</td>
	  </tr>
	</table>
	<p>
		<input type="button" value="bold" onclick="formatText ('b');" />
		<input type="button" value="italic" onclick="formatText ('i');" />
		<input type="button" value="underline" onclick="formatText ('u');" /><br/>
		Set text size:
		<input type="button" value="large" onclick="setFontSize ('x-large');" />
		<input type="button" value="largest" onclick="setFontSize ('xx-large');" /><br/>
	   <label>Text:<br/>
	   <textarea name="articleText" id="articleText" class="article_text"  cols="75" rows="100"></textarea>
	   </label>
	</p>


	<input name="id" type="hidden" value="$myrow[id]">

	 <p>
	   <label>
	   <input name="submit" type="submit" class="main-content-buttons" id="submit" value="Save Article">
	   </label>
	</p>
</form>

<?php include('../views/layouts/_footer.php'); ?>
